package com.sc.common.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class CommonController {

    @RequestMapping("/login")
    public String login(String loginType) {
        String view = null;
        if ("student".equals(loginType))
            view = "forward:/student/login";
        else if ("teacher".equals(loginType))
            view = "forward:/teacher/login";
        else if ("admin".equals(loginType))
            view = "forward:/admin/login";

        return view;
    }


    @RequestMapping("/getCode")
    @ResponseBody
    public String getCode(HttpSession session) {
        System.out.println((String) session.getAttribute("KAPTCHA_SESSION_KEY"));
        return (String) session.getAttribute("KAPTCHA_SESSION_KEY");
    }
}
